//
//  ImageLoop.swift
//  YeKa
//
//  Created by Gina on 15/10/15.
//  Copyright © 2015年 Gina. All rights reserved.
//

import UIKit


class ImageLoop: NSObject {
    
    var webUrl: String?
    var imageUrl: String?
    var sort: Int = 0
    
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    class func loadImageLoops(finished: (dataList: [ImageLoop]?, error:NSError?) -> ()){
        let urlString = "recommend?="
   
        NetworkTools.sharedNetworkTools.request(YeKaNetworkMethod.GET, urlString: urlString, params: nil) { (result, error) -> () in
            
            if let array = result?["data"]?["list"] as? [[String: AnyObject]] {
                var list = [ImageLoop]()
                for dict in array {
                    list.append(ImageLoop(dict: dict))
                }
                finished(dataList: list, error: nil)
            }else{
                finished(dataList: nil, error: nil)
            }
        }
  
    }

}
